package home;

import org.apache.wicket.Page;
import org.apache.wicket.authroles.authentication.AbstractAuthenticatedWebSession;
import org.apache.wicket.authroles.authentication.AuthenticatedWebApplication;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;

import services.GeneralService;

public class MyApplication extends AuthenticatedWebApplication{
	
	private MounterURL aMounterURL;
	
    private GeneralService generalService;

	@Override
	protected Class<? extends WebPage> getSignInPageClass() {
		 return Home.class;
	}

	@Override
	protected Class<? extends AbstractAuthenticatedWebSession> getWebSessionClass() {
		 return WebSession.class;
	}

	@Override
	public Class<? extends Page> getHomePage() {
		 return Home.class;
	}
	
	public String getContextPath() {
	    return this.getServletContext().getContextPath();
	}
	
    @Override
    public void init() {
        aMounterURL = new MounterURL(this);
        // Linea magica //
        this.getComponentInstantiationListeners().add(new SpringComponentInjector(this));
        // ////////////////
        this.mountUrl("home", Home.class, "");
    }
    
    private void mountUrl(final String mountPath, final Class<? extends WebPage> pageClass, final String... parameters) {
        aMounterURL.mount(mountPath, pageClass, parameters);
    }

	//-----------Gett&Sett------------
	
	public GeneralService getGeneralService() {
		return generalService;
	}

	public void setGeneralService(GeneralService generalService) {
		this.generalService = generalService;
	}

	public MounterURL getaMounterURL() {
		return aMounterURL;
	}

	public void setaMounterURL(MounterURL aMounterURL) {
		this.aMounterURL = aMounterURL;
	}

}
